The present invention relates to the optimization of computer program instructions. More particularly, the present invention relates to a compiler program that utilizes a profiling optimization system.
The development of the EDVAC computer system of 1948 is often cited as the beginning of the computer era. Since that time, dramatic advances in both hardware (i.e., the computer""s electronic components) and software (i.e., computer programs) have drastically improved the performance of computer systems. However, modem software programs, often containing millions of instructions, have become very complex when compared with early computer programs. Because the execution time (and hence, performance) of a computer program is very closely related to the number of instructions contained in the program, developers must continue to find new ways of improving the efficiency of computer software.
Most modem computer programs are typically written in a high-level language that is easy to understand by a human programmer. Special software tools, known as compilers, take the human-readable form of a computer program, known as xe2x80x9csource code,xe2x80x9d and convert it into machine-readable instructions, known as xe2x80x9cobject code.xe2x80x9dBecause a compiler generates the stream of instructions that are eventually executed on a computer system, the manner in which the compiler converts the source code into object code affects the execution time of the computer program.
As noted, the continual desire to use larger, faster and more complex software programs has forced system developers to find new methods of improving the rate at which programs run. Software developers have focused a great deal of effort on developing methods of generating efficient computer instructions that can take full advantage of the hardware systems on which they are to be executed. Such methods of improving the sequencing or placement of computer instructions within a computer program are referred to as optimizations. Numerous optimization techniques to improve the performance of software are known in the art today.
Profiling is one technique that can be used to improve software optimization. Profiling uses predicted information on how a program will run to further optimize the computer program. For example, if it is known that certain blocks of code (i.e., distinct portions of a program) will be executed more often than other code blocks, performance may be enhanced by handling those blocks of code in a particular manner. (E.g., it might be desirable to position the code blocks in memory in a manner that improves the utilization of cache memory.) Thus, profiling seeks to improve optimizations and therefore system performance by using information regarding the expected behavior of blocks of code within a computer program. Specifically, by identifying frequently used code blocks and execution paths, software programs can be created to maximize the performance of the hardware on which they will run.
In order to implement any profiling system, accurate profile or behavior information must be collected by first running the program on a set of inputs believed to represent typical operating conditions. Collecting profile information is referred to as xe2x80x9cbenchmarking.xe2x80x9dOnce the profile information is collected, it can then be used for optimization purposes during a subsequent compilation of the source code used to build the program. Various known methods of optimizing program code with profile data exist.
While most profiling mechanisms are fairly automated (e.g., compilers often include automated mechanisms for facilitating profiling), the actual process of profiling a software program can become fairly time consuming and costly as the size and complexity of the program grows. One recognized limitation with profiling is that as software errors (i.e., bugs) are identified and corrected, the entire profiling of the program must often be repeated. Under typical conditions, it would be inappropriate to use old profiling data with a modified software program because the execution paths traversed in the modified code may differ significantly from the execution paths traversed in the original code for which the profile data was gathered. Furthermore, if new procedures are added, additional instrumentation code may be required to properly profile the program. Thus, with respect to profiling, a potentially significant amount of overhead is created each time a software program is modified.
This problem may not be that serious as long as the software program is relatively small. However, with larger programs, such as operating systems that may contain thousands of source code modules and millions of lines of source code, the time and expense involved in re-profiling the program each time a minor bug fix occurs may be significant. Moreover, delivering a bug fix (i.e., a patch) to the customer may then require shipping an entire new product, which creates additional overhead and expense to both the developer and the customer. At present, no other viable option exists (which does not result in serious performance degradation) except to reprofile the entire program after each source code modification.
Thus, because of the economic drawbacks involved, present profiling methodologies cannot be effectively used with complex commercial software products, such as operating systems. Without a profiling system and method that can support bug-fixing without significantly sacrificing system performance, the use of profiling in large systems will be limited.
The present invention provides a system and method that organizes profile information in a hierarchical fashion in order to eliminate the need to re-profile a program each time a software error is fixed. The apparatus and method disclosed herein causes profile information to be stored in procedure specific storage areas during the benchmarking phase and then, during the optimization phase, provides a system for identifying and utilizing valid profile information (and ignoring invalid profile information) as each procedure is processed.
The invention features a compiler system that includes a code generator for converting a first instruction module into a second instruction module; an instrumentation mechanism for inserting instrumentation code into the second instruction module and for initializing procedure specific data storage areas for each procedure within the first instruction module being compiled; and an optimization mechanism that optimizes using any available valid procedure specific profile data. The invention may further comprise a harvesting mechanism that can organize procedure specific profile information into files readable by the above-described optimization mechanism.
The invention further features a method of generating and utilizing profile data for a computer program that is built from at least one source code module wherein the method comprises the steps of: creating an instrumented executable program that includes a process for generating procedure specific profile data; benchmarking the instrumented executable program and storing profile information in procedure specific data areas; and optimizing the source code module such that the procedures that have not been modified since the benchmarking step will be processed using said procedure specific profile data while the procedures that have been modified since the benchmarking step will be processed without procedure specific profile data.
The invention also features a system and method for reordering procedures within an object module or executable module that uses procedure specific profile data. In particular, the system and method provide an improved system for determining the order of procedures even in the case where significant source code changes, such as the addition or deletion of entire procedures, took place.
Therefore, it is an advantage of the present invention to provide a profiling system that will permit bug fixes and program improvements to occur without serious loss of performance and without rebuilding or rebenchmarking an entire software product. It is therefore a further advantage of the present invention to provide a profiling system in which profile data is stored in a hierarchical and separable fashion. It is therefore a further advantage of the present invention to have a separate unique profile data file for each source code module that is used to build a software product. It is therefore a further advantage of the present invention to have a unique area for holding profile data for each procedure of a source code module. It is a further advantage of the present invention to provide an optimization system in which module counter areas and procedure counter areas can be checked for their existence and validity.